<!DOCTYPE html>
<html>
<head>
	<title></title>
	
	<script src="/static/incubator-echarts-4.2.1/incubator-echarts-4.2.1/dist/echarts.min.js"></script>
	<script src="/static/incubator-echarts-4.2.1/incubator-echarts-4.2.1/dist/echarts.js"></script>
	<script type="text/javascript" src="/static/jquery-3.3.1.min.js"></script>
</head>
<body>
	 <div id="main" style="width: 600px;height:400px;"></div>

	<script type="text/javascript">
		/*var myChart = echarts.init(document.getElementById('main'));

		var arr1=[],arr2=[];
		function arrTest()
		{
			var test='aaa';
			$.ajax({
				type:"post",

				url:"/backend/graph/data",
				data:{test:test},
				dataType:"json",
				success:function(result)
				{
					console.log('111');
					if(result)
					{
						for(var i=0;i<result.length;i++)
						{
							arr1.push(result[i].amount);
							arr2.push(result[i].month);
						}
					}
				}
				
			});
			return arr1,arr2;

		};
		arrTest();
	
 

		var option = {
            title: {
                text: 'ECharts 入门示例'
            },
            tooltip: {},
            legend: {
                data:['amount']//图例
            },
            xAxis: {
            	type:'category',
                data: arr2
            },
            yAxis: {
            	
            	type:'value'
            },
            series: [{
                name: 'amount',
                type: 'bar',
                data: arr1
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
*/
	</script>
<script type="text/javascript">
	 myChart = echarts.init(document.getElementById('main'));

        var arr1=[],arr2=[],arr3=[];
              function arrTest(){
                $.ajax({
                  type:"post",
                  data:{data:'111'},
                  url:"/backend/graph/data1",
                 async:false,
                  dataType:"json",
                  success:function(result){
                  	console.log('111');
                    if (result) {
                      for (var i = 0; i < result.length; i++) {
                          arr1.push(result[i].day);
                          arr2.push(result[i].result);
                          arr3.push(result[i].result);
                      }
                    }
                    console.log(arr1);
                    console.log(arr2);
                  }
                });
                return arr1,arr2,arr3;
                console.log(arr1);
              }
              arrTest();
    
console.log(arr1);
console.log(arr2);
    
        // 指定图表的配置项和数据
       var option = {
            title: {
                text: 'ECharts 入门示例'
            },
            tooltip: {},
            legend: {
               
            },
            xAxis: {
                
                data:arr1
            },
            yAxis: {
                
            },
            series: [{
                    name:'result',
                    type:'line',
                    data:arr2
            },

             {
             	 name: 'result1',
            type: 'bar',
           
            data: arr3
        }
            ]

        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
</script>

</body>
</html>